// web/src/components/auth/social.tsx
'use client';
import React from 'react';
import {Button} from "@/components/ui/button";
import {FaGithub} from "react-icons/fa";
import {FcGoogle} from "react-icons/fc";
import {signIn} from "next-auth/react";
import {DEFAULT_LOGIN_REDIRECT} from "@/routes";

// timeout 防火墙...
const Social = () => {
    const onClick = (provider: "google" | "github") => {
        // 如果当前数据库里有相同邮箱的, 就不会插入新数据, 所以要先删除
        signIn(provider, {
            callbackUrl: DEFAULT_LOGIN_REDIRECT
        })
    }

    return (
        <div className={`flex items-center w-full gap-x-2`}>
            <Button
                size={'lg'}
                variant={'outline'}
                onClick={() => onClick('google')}
                className={`w-full`}>
                <FcGoogle className="w-5 h-5"/>
            </Button>
            <Button
                size={'lg'}
                variant={'outline'}
                onClick={() => onClick('github')}
                className={`w-full`}>
                <FaGithub className="w-5 h-5"/>
            </Button>
        </div>
    );
};

export default Social;